package com.ang.filter.controller;

import com.alibaba.fastjson.JSON;
import com.ang.filter.dto.TestReqDto;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/filter")
public class TestFilterController {

    @PostMapping("/test1")
    public void test1(@RequestBody TestReqDto reqDto){
        System.out.println("进入controller::test1");

        //制造500错误，为了让请求被MyFilterRegistrationBean2拦截到
        int i = 5 / 0;

        System.out.println("入参：" + JSON.toJSONString(reqDto));
    }

    @PostMapping("/test2")
    public void test2(@RequestBody TestReqDto reqDto){
        System.out.println("进入controller::test2");

        System.out.println("入参：" + JSON.toJSONString(reqDto));
    }
}
